import { ObjCreate } from "../common/ObjCreate";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { LayerManager } from "../../manager/LayerManager";
import { GameController } from "../../mvc/GameController";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { Cache } from "../../cache/Cache";
import { AIManager } from "../../scene/ai/AIManager";
//class PackFullTips
    
    export  class PackFullTips /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ObjCreate.createTextField("", 0, 0, 100, 20, this);
            loc1.htmlText = HTMLUtil.addColor(Language.getString(40063), "#ff0000");
            var loc2=ObjCreate.createTextField("", 0, 20, 200, 40, this);
            loc2.multiline = true;
            loc2.wordWrap = true;
            loc2.htmlText = "<textFormat leading=\'7\'>" + Language.getString(40064) + "<a href=\'event: 1\'><u>" + HTMLUtil.addColor(Language.getString(40065), "#00FF00") + "</u></a>" + Language.getString(40066) + "<a href=\'event: 2\'><u>" + HTMLUtil.addColor(Language.getString(40067), "#00FF00") + "</u></a>" + "、或" + "<a href=\'event: 3\'><u>" + HTMLUtil.addColor(Language.getString(40068), "#00FF00") + "</u></a>";
            loc2.addEventListener(flash.events.TextEvent.LINK, this.onTextClick);
            return;
        }

        /* internal  */onTextClick(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=null;
            var loc2=arg1.text;
            switch (loc2) 
            {
                case "1":
                {
                    LayerManager.windowLayer.centerWindows(GameController.equipment.view, GameController.pack.view, 20);
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BackPackShowTabIndex, 2));
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_EquipDecompose, null));
                    break;
                }
                case "2":
                {
                    if (Cache.instance.vip.isVIP) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.VIPStorageOpen));
                    }
                    else 
                    {
                        loc1 = Cache.instance.scene.getNearlyWareHouseNpc();
                        AIManager.onAutoPathAIControl(loc1);
                    }
                    break;
                }
                case "3":
                {
                    LayerManager.windowLayer.centerWindows(GameController.smelt.view, GameController.pack.view, 20);
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BackPackShowTabIndex, 1));
                    break;
                }
                default:
                {
                    break;
                }
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.MsgTipWindowHide));
            return;
        }
    }
